package com.woniuxy.microgoodsserver.auctionmag.mapper;

import com.woniuxy.microgoodsserver.bean.GoodsUnitBean;
import com.woniuxy.microgoodsserver.bean.ImageBean;
import com.woniuxy.microgoodsserver.bean.ImageXcBean;
import com.woniuxy.microgoodsserver.bean.PageRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ImageXcMapper {
    //相册通过id查询
    @Select("select id,image_name as imageName,image_ms as imageMs from t_image_xc_info where id = #{id} and del_status=0")
    ImageXcBean xcFindAllById(@Param("id")int id);

    //相册分页查询
    List<ImageXcBean> imageXcFindAll(@Param("p") PageRequest request, @Param("x")ImageXcBean ImageXcBean);



    //相册增加
    @Options(useGeneratedKeys = true,keyProperty = "x.id")
    @Insert("insert into t_image_xc_info " +
            "(image_name,image_ms,del_status)" +
            " values(#{x.imageName},#{x.imageMs},'0')")
    int SaveXc(@Param("x") ImageXcBean imageXcBean);


    //相册修改
    @Update("<script>" +
            "update t_image_xc_info" +
            "<set>" +
            "<if test='x.imageName != null'>" +
            " image_name = #{x.imageName}," +
            "</if>" +
            "<if test='x.imageMs != null'>" +
            " image_ms = #{x.imageMs}," +
            "</if>" +
            "</set>" +
            "where id = #{u.id}" +
            "</script>")
    int updateXc(@Param("x") ImageXcBean imageXcBean);

    //相册删除
    @Update("<script>" +
            "update t_image_xc_info" +
            "<set>" +
            " del_status = '1'" +
            "</set>" +
            "where id = #{x.id}" +
            "</script>")
    int delXc(@Param("x") ImageXcBean imageXcBean);
}
